package com.exam.commonbiz.util;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.os.Build;
import android.text.TextUtils;

/**
 * @Author yuexingxing
 * @time 2020/6/11
 */
public class AppUtil {

    private static final String LIVE_PHONE_IMEI = "357710606800992";//大屏幕直播手机

    /**
     * 判断是debug还是release模式
     * 注意gradle中是否已经配置，正常情况不需要配置
     */
    public static boolean isDebug(Context context) {
        boolean isDebug = context.getApplicationInfo() != null &&
                (context.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
        return isDebug;
    }

    /**
     * 是不是楼下的大屏直播手机
     * @return
     */
    public static boolean isBigScreenLivePhone(){
        return TextUtils.equals(LIVE_PHONE_IMEI, getIMEI());
    }

    /**
     * 获取手机品牌
     * @return
     */
    public static String getBrand(){
        return Build.BRAND;
    }

    /**
     * 获取手机型号
     * @return
     */
    public static String getModel(){
        return Build.MODEL;
    }

    /**
     * 获取手机Android 版本
     * @return
     */
    public static String getRelease(){
        return Build.VERSION.RELEASE;
    }


    /**
     * 获取手机IMEI(需要“android.permission.READ_PHONE_STATE”权限)
     *
     * @return 手机IMEI
     */
    public static String getIMEI() {
        return "35" + Build.BOARD.length() % 10 +
                Build.BRAND.length() % 10 +
                Build.CPU_ABI.length() % 10 +
                Build.DEVICE.length() % 10 +
                Build.DISPLAY.length() % 10 +
                Build.HOST.length() % 10 +
                Build.ID.length() % 10 +
                Build.MANUFACTURER.length() % 10 +
                Build.MODEL.length() % 10 +
                Build.PRODUCT.length() % 10 +
                Build.TAGS.length() % 10 +
                Build.TYPE.length() % 10 +
                Build.USER.length() % 10; //13 digits
    }
}
